import { Store } from "@/low-code/utils/store.js"

export class DataSource {
  store
  constructor(store) {
    this.store = store
    this.initDataSource()
    this.autoRequest()
  }

  initDataSource(){
     
  }

  autoRequest(){
    let formDataSource = this.store.formDataSource

    Object.values(formDataSource).map(source=>{
        if (source.type=='interface' &&  source.auto=='1') {
             Store.axios({ method: source.method, url: source.url , params:{} }).then(res=>{
                 console.log("🚀 ~ file: dataSource.js ~ line 21 ~ DataSource ~ Store.axios ~ res", res)
             }).catch(err=>{
             console.log("🚀 ~ file: dataSource.js ~ line 31 ~ DataSource ~ Store.axios ~ err", err)
             source.data=[
                {
                    label:'小龙虾',
                    value:'xiaolongxia'
                },{
                  label:'羊肉串',
                  value:'yangrouchuan'
              },
            ]
             })
        }
    })
  }

}